﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using Treely.Data.Model.Abstract;

namespace Treely.Data.Model.RandomMath
{
    public class MathQuiz : AuditObject
    {
        [Key]
        public int MathQuizId { get; set; }

        public string Title { get; set; }

        public ICollection<IAnswerable> Questions { get; set; }

        [ForeignKey("Author")]
        public string AuthorId { get; set; }

        public virtual ApplicationUser Author { get; set; }

        public int StartedAssessments { get; set; }

        public int FinishedAssessments { get; set; }

        public virtual ICollection<ApplicationUser> Users { get; set; }

        public virtual ICollection<Assessment> Assessments { get; set; }

        public DifficultyLevel Addition { get; set; }

        public DifficultyLevel Subtraction { get; set; }

        public DifficultyLevel Multiplication { get; set; }

        public DifficultyLevel Division { get; set; }

        public int? QuestionLength { get; set; }

        public TimeSpan? RequiredTime { get; set; }

        public List<QuestionSubject> Subjects
        {
            get
            {
                if (Questions == null) return null;
                return Questions.Select(x => x.Subject).ToList();
            }
        }
    }
}